package com.lin.baby.boot.chapter4;

import com.lin.baby.boot.chapter4.config.CustomAsyncConfig;
import com.lin.baby.boot.chapter4.service.AsyncTaskService;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * Class Desc
 *
 * @author WangYang
 * @version 1.0
 * @datetime 2016/10/14 10:21
 */
public class MainChapter4 {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(CustomAsyncConfig.class);
        AsyncTaskService cnAsyncTaskService = context.getBean("cnAsyncTaskService", AsyncTaskService.class);
        AsyncTaskService enAsyncTaskService = context.getBean("enAsyncTaskService", AsyncTaskService.class);

        for (int i = 0; i < 10; i++) {
            cnAsyncTaskService.execute(i);
            enAsyncTaskService.execute(i);
        }

        context.close();
    }

}
